<?php
   	include_once "../funciones.php";
        include_once "../validacionPHP/validacion.php";
    validar();

    $con=conectar();
    $today = date("d-M-Y");
    $fallo=false;
   try {
        $con->beginTransaction();
        $sql="INSERT INTO LINEAS_PRESTAMOS VALUES  (".$_REQUEST['OID_MAT'].", ".$_REQUEST['oid_inf'].", ".$_REQUEST['CANTIDAD'].")";
        $stmt = $con->prepare($sql);
        $stmt->execute();
		$stmt = $con->prepare("commit");
	    $stmt->execute();
	}catch(PDOException $e ) {
			echo "error: ".$e->GetMessage();
            $con->rollBack();
             header( 'Location: insertarPrestamos.php?exito=2&oid_inf='.$_REQUEST['oid_inf']);
   	        $fallo=true;

	}
    if($fallo==false)
        header( 'Location: insertarPrestamos.php?exito=1&oid_inf='.$_REQUEST['oid_inf'].'&OID_CAM='.$_REQUEST['OID_CAM']);


   ?>